//
//  XYNetworkStatusHelper.m
//  PeiJue
//
//  Created by lxy on 2017/12/6.
//  Copyright © 2017年 lixiya. All rights reserved.
//

#import "XYNetworkStatusHelper.h"

@implementation XYNetworkStatusHelper

+ (XYNetworkStatusHelper *)sharedInstance
{
    static XYNetworkStatusHelper *obj = nil;
    static dispatch_once_t predicate;
    dispatch_once(&predicate, ^{
        obj = [[XYNetworkStatusHelper alloc] init];
    });
    return obj;
}


#pragma makr - 开始监听网络连接
- (void)startMonitoring
{
    AFNetworkReachabilityManager *mgr = [AFNetworkReachabilityManager sharedManager];
    [mgr startMonitoring];
    
    [mgr setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
        // 当网络状态改变了, 就会调用这个block
        switch (status)
        {
            case AFNetworkReachabilityStatusUnknown: // 未知网络
                
                self.networkStats = StatusUnknown;
                
                break;
            case AFNetworkReachabilityStatusNotReachable: // 没有网络(断网)
                
                self.networkStats = StatusNotReachable;
                break;
            case AFNetworkReachabilityStatusReachableViaWWAN: // 手机自带网络
                
                //[[ManaStaticDataHelper sharedInstance] initilizeStaticData];
                self.networkStats = StatusReachableViaWWAN;
                break;
            case AFNetworkReachabilityStatusReachableViaWiFi: // WIFI
                
                //[[ManaStaticDataHelper sharedInstance] initilizeStaticData];
                self.networkStats = StatusReachableViaWiFi;
                break;
        }
    }];
}

@end
